<template>
  <el-form>
    <el-form-item label="名称">
      <el-input v-model.trim="user.name"/>
    </el-form-item>
    <el-form-item label="电话">
      <el-input v-model.trim="user.mobile"/>
    </el-form-item>
    <el-form-item label="邮件">
      <el-input v-model.trim="user.email"/>
    </el-form-item>
    <el-form-item label="简介">
      <el-input type="textarea" rows="3" v-model.trim="user.introduction"/>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submit">提交</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
  export default {
    props: {
      user: {
        type: Object,
        default: () => {
          return {
            name: '',
            email: ''
          }
        }
      }
    },
    methods: {
      submit() {
        this.$api.user.updateLoginUser(this.user).then((res) => {
          if (res.code === 200) {
            this.$message({
              message: '保存成功, 重新登录生效',
              type: 'success',
              duration: 5 * 1000
            })
          }
        });
      }
    }
  }
</script>
